//
//  WYCCreditCell.m
//  初试
//
//  Created by 中企互联 on 2017/10/11.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCCreditCell.h"

@interface WYCCreditCell ()

/** 银行图标*/
@property(nonatomic,strong)UIImageView * bankImageView;

/** 顶部View */
@property (nonatomic,strong) UIView *topView;

/** 顶部View */
@property (nonatomic,strong) UIImageView *bigtopView;

/** 银行名称*/
@property (nonatomic,strong)UILabel * banklabel;

/** 姓名*/
@property (nonatomic,strong)UILabel * namelabel;

/** 尾号*/
@property (nonatomic,strong)UILabel * lsnameberlabel;

/** 账单日.天*/
@property (nonatomic,strong)UILabel * Statementlabel;

/** 账单日.出账单*/
@property (nonatomic,strong)UILabel * accountlabel;

/** 是否认证*/
@property (nonatomic,strong)UILabel * typelabel;
/** 还款日*/
@property (nonatomic,strong)UILabel * staylabel;

/** 本期账单余额*/
@property (nonatomic,strong)UILabel * balancelabel;

@end
@implementation WYCCreditCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    WYCCreditCell * cell = [tableView dequeueReusableCellWithIdentifier:[WYCCreditCell ID]];
    cell = [[WYCCreditCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[WYCCreditCell ID]];
    cell.backgroundColor = WYCGlobalBg;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}
//cell控件摆放
- (void)setMember{
    
    
    /** 顶部View */
    self.topView = [[UIView alloc] init];
    self.topView.layer.shadowOffset = CGSizeMake(0, -2);
    
    self.topView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.topView];
    
    self.bigtopView = [[UIImageView alloc] init];
    
    //    self.bigtopView.backgroundColor = [UIColor whiteColor];
    self.bigtopView.layer.cornerRadius = 10 * px;
    
    self.bigtopView.layer.masksToBounds = YES;
    

    [self.topView addSubview:self.bigtopView];
    
    /** 银行图标*/
    self.bankImageView = [[UIImageView alloc] init];
    //    self.bankImageView.backgroundColor = [UIColor redColor];
    [self.bigtopView addSubview:self.bankImageView];
    
    /** 银行名称*/
    self.banklabel = [[UILabel alloc] init];
    self.banklabel.font = [UIFont systemFontOfSize:BigMiddleFont];
    self.banklabel.textColor = [UIColor whiteColor];
    [self.bigtopView addSubview:self.banklabel];
    
    
    /** 姓名*/
    self.namelabel = [[UILabel alloc] init];
    self.namelabel.textColor = [UIColor whiteColor];
    self.namelabel.font = [UIFont systemFontOfSize:40 * px];
    [self.bigtopView addSubview:self.namelabel];
    
    /** 尾号*/
    self.lsnameberlabel = [[UILabel alloc] init];
    self.lsnameberlabel.textColor = [UIColor whiteColor];
    self.lsnameberlabel.font = BigLight;
    [self.bigtopView addSubview:self.lsnameberlabel];
    
    ////////////////
    //////分割线/////
    ///////////////
    UIView * topView = [[UIView alloc] init];
    topView.frame = CGRectMake(0, CGRectGetMaxY(self.bankImageView.frame) +  20 * px, self.topView.width, 1);
    topView.backgroundColor = WYCRGBColor(255, 255, 255);
    [self.bigtopView addSubview:topView];
    
    
    
    /** 判断还款类型*/
    self.typelabel = [[UILabel alloc] init];
    //    self.typelabel.backgroundColor = WYCRGBColor(207, 105, 69);
    self.typelabel.textAlignment = NSTextAlignmentCenter;
    self.typelabel.textColor = [UIColor whiteColor];
    
    self.typelabel.font = [UIFont systemFontOfSize:SmallFont];
    [self.bigtopView addSubview:self.typelabel];
    
    
    
    /** 账单日.天*/
    self.Statementlabel = [[UILabel alloc] init];
    self.Statementlabel.textColor = WYZBlackBg;
    self.Statementlabel.font = [UIFont boldSystemFontOfSize:MiddleFont];
    [self.bigtopView addSubview:self.Statementlabel];
    
    
    
    /** 账单日.出账单*/
    self.accountlabel = [[UILabel alloc] init];
    self.accountlabel.textColor = WYCRGBColor(186, 186, 186);
    self.accountlabel.font = smallLight;
    [self.bigtopView addSubview:self.accountlabel];
    
    /** 还款日*/
    self.staylabel = [[UILabel alloc] init];
    self.staylabel.textColor = WYCRGBColor(186, 186, 186);
    self.staylabel.font = smallLight;
    [self.bigtopView addSubview:self.staylabel];
    
    
    ////////////////
    //////分割线/////
    ///////////////
    
    /** 本期账单余额*/
    self.balancelabel = [[UILabel alloc] init];
    self.balancelabel.textColor = WYCRGBColor(186, 186, 186);
    self.balancelabel.font = smallLight;
    [self.bigtopView addSubview:self.balancelabel];
    
    //
    //
    
}

- (void)setBillmodelFrame:(WYCRepayFramModel *)billmodelFrame{
    _billmodelFrame = billmodelFrame;
    
    WYCBillModel * Billmodel = billmodelFrame.Billmodel;
    
    self.topView.frame = billmodelFrame.topViewF;
    
    
    self.bigtopView.frame = billmodelFrame.bigtopViewF;
    
    
    //银行图片
    self.bankImageView.frame = billmodelFrame.imageViewF;
    
    
    NSInteger bankid = [billmodelFrame.Billmodel.bankId integerValue];
    self.bankImageView.layer.borderWidth = 10 * px;
    self.bankImageView.layer.cornerRadius = 50 * px;
    self.bankImageView.layer.borderColor = [[UIColor whiteColor] CGColor];
    
    switch (bankid) {
        case 10000://招商银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_zhaoshang"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10001://工商银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_gs"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10002://农业银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_ny"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_green"];
            break;
        case 10003://  建设银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_js"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10004://中国银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_zhongguo"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10005:  //浦发银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_pufa"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10006:  //交通银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_jiaotong"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10007:  //民生银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_minsheng"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_green"];
            break;
        case 10009:  //广东发展银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_gf"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10010:  //中信银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_zhongxin"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10011:  //  华夏银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_hx"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10012:  //  兴业银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_xingye"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10014:  //  江苏银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_jiangsu"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10016:  //  北京银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_bj"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_red"];
            break;
        case 10020://10020  光大银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_gd"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case  10024://平安银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_pinan"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case 10027:  //上海银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_shanghai"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_blue"];
            break;
        case  10028://  中国邮政储蓄银行
            self.bankImageView.image = [UIImage imageNamed:@"bank_circle_youzheng"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_green"];
            break;
            
        default:
            self.bankImageView.image = [UIImage imageNamed:@"icon_other_bank"];
            self.bigtopView.image = [UIImage imageNamed:@"repayment_green"];
            break;
    }
    
    //银行名称
    self.banklabel.frame = billmodelFrame.bankNameF;
    
    self.banklabel.text = [NSString stringWithFormat:@"%@",Billmodel.bankName];
    
    self.namelabel.text = @"信用卡";
    self.namelabel.frame = CGRectMake(_banklabel.x, CGRectGetMaxY(_banklabel.frame), 150 * px, 50 * px);
    
    
    
    //尾号
    self.lsnameberlabel.frame = billmodelFrame.lastNumberF;
    NSString * lastNumberStr = [NSString stringWithFormat:@"****  ****  ****  %@",Billmodel.lastNumber];
    self.lsnameberlabel.text = lastNumberStr;
    
}
- (void)repayMentClick{
    
    WYCLogFunc;
}
+(NSString *)ID{
    return @"cell";
}

@end

